package com.tensqure.jwt;

import io.jsonwebtoken.JwtBuilder;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;

import java.util.Date;

public class CreateJwt {
    public static void main(String[] args) {
        JwtBuilder jwtBuilder = Jwts.builder()
                .setId("uerid")
                .setSubject("username")
                .setIssuedAt(new Date())
                .signWith(SignatureAlgorithm.HS256,"itcase")
                .claim("role","admin")
                .setExpiration(new Date(new Date().getTime()+60000));
        //sigWith(头部，盐)
        //返回生成的字符串
        System.out.println(jwtBuilder.compact());
    }
}
